<template>
  <div class="home-container">
    <!-- 页面顶部欢迎区域 -->
    <div class="welcome-section">
      <div class="welcome-content">
        <h1 class="welcome-title">欢迎来到 AIGC-OJ</h1>
        <p class="welcome-subtitle">人工智能辅助的在线编程挑战平台</p>
        <div class="action-buttons">
          <a-button type="primary" size="large" @click="goToQuestions">
            开始刷题
            <template #icon><icon-right /></template>
          </a-button>
          <a-button size="large" @click="goToAIChat">
            AI 助手
            <template #icon><icon-robot /></template>
          </a-button>
        </div>
      </div>
    </div>

    <!-- 主要内容区域 -->
    <div class="main-content">
      <!-- 快捷入口卡片区域 -->
      <div class="quick-access-section">
        <h2 class="section-title">快捷入口</h2>
        <div class="card-grid">
          <a-card class="quick-card" @click="goToQuestions">
            <template #cover>
              <div class="card-icon-wrapper blue">
                <icon-code-square size="32" />
              </div>
            </template>
            <a-card-meta title="刷题中心" :description="'浏览和挑战编程题目'" />
          </a-card>

          <a-card class="quick-card" @click="goToSubmissions">
            <template #cover>
              <div class="card-icon-wrapper green">
                <icon-history size="32" />
              </div>
            </template>
            <a-card-meta title="提交记录" :description="'查看你的解题历史'" />
          </a-card>

          <a-card class="quick-card" @click="goToAIReport">
            <template #cover>
              <div class="card-icon-wrapper purple">
                <icon-bulb size="32" />
              </div>
            </template>
            <a-card-meta title="智能分析" :description="'AI 代码优化与解析'" />
          </a-card>

          <a-card class="quick-card" @click="goToCompetitions">
            <template #cover>
              <div class="card-icon-wrapper orange">
                <icon-trophy size="32" />
              </div>
            </template>
            <a-card-meta title="竞赛中心" :description="'参与编程竞赛，提升技能'" />
          </a-card>

          <a-card class="quick-card" @click="goToProfile">
            <template #cover>
              <div class="card-icon-wrapper orange">
                <icon-user size="32" />
              </div>
            </template>
            <a-card-meta title="个人中心" :description="'管理你的个人资料'" />
          </a-card>
        </div>
      </div>

      <!-- 统计数据卡片 -->
      <div class="stats-section">
        <h2 class="section-title">学习进度</h2>
        <div class="stats-grid">
          <a-card class="stats-card">
            <h3>已完成题目</h3>
            <div class="stats-value">3</div>
            <a-progress :percent="0.5" />
          </a-card>

          <a-card class="stats-card">
            <h3>提交次数</h3>
            <div class="stats-value">48</div>
          </a-card>

          <a-card class="stats-card">
            <h3>连续打卡</h3>
            <div class="stats-value">5</div>
            <div class="streak-days">天</div>
          </a-card>
        </div>
      </div>
    </div>
  </div>
</template>

<script setup lang="ts">
import { onMounted } from 'vue';
import { useRouter } from 'vue-router';
import { useStore } from 'vuex';
import { 
  IconRight, 
  IconRobot, 
  IconCodeSquare, 
  IconHistory, 
  IconBulb, 
  IconUser,
  IconTrophy
} from '@arco-design/web-vue/es/icon';

const router = useRouter();
const store = useStore();

// 导航函数
const goToQuestions = () => {
  router.push('/questions');
};

const goToSubmissions = () => {
  router.push('/question_submit');
};

const goToAIReport = () => {
  router.push('/ai_report');
};

const goToAIChat = () => {
  router.push('/chat');
};

const goToProfile = () => {
  router.push('/user/profile');
};

const goToCompetitions = () => {
  router.push('/competitions');
};

onMounted(() => {
  // 可以在这里加载用户数据、统计信息等
  console.log('首页组件已加载');
});
</script>

<style scoped>
.home-container {
  min-height: 100vh;
  width: 100%;
  background-color: #f5f7fa;
}

/* 欢迎区域样式 */
.welcome-section {
  background: linear-gradient(120deg, #4080ff, #7aaaff);
  color: white;
  padding: 60px 0;
  text-align: center;
}

.welcome-content {
  max-width: 1200px;
  margin: 0 auto;
  padding: 0 20px;
}

.welcome-title {
  font-size: 2.8rem;
  font-weight: 700;
  margin-bottom: 16px;
}

.welcome-subtitle {
  font-size: 1.4rem;
  margin-bottom: 40px;
  opacity: 0.9;
}

.action-buttons {
  display: flex;
  gap: 16px;
  justify-content: center;
}

/* 主要内容区域 */
.main-content {
  max-width: 1200px;
  margin: 0 auto;
  padding: 40px 20px;
}

.section-title {
  font-size: 1.8rem;
  font-weight: 600;
  margin-bottom: 24px;
  color: #333;
}

/* 快捷入口卡片 */
.quick-access-section {
  margin-bottom: 40px;
}

.card-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(250px, 1fr));
  gap: 24px;
}

.quick-card {
  cursor: pointer;
  transition: all 0.3s ease;
  height: 100%;
}

.quick-card:hover {
  transform: translateY(-5px);
  box-shadow: 0 12px 24px rgba(0, 0, 0, 0.1);
}

.card-icon-wrapper {
  display: flex;
  justify-content: center;
  align-items: center;
  height: 80px;
  color: white;
}

.blue {
  background-color: #4080ff;
}

.green {
  background-color: #00b42a;
}

.purple {
  background-color: #722ed1;
}

.orange {
  background-color: #ff7d00;
}

/* 统计数据卡片 */
.stats-section {
  margin-bottom: 40px;
}

.stats-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(300px, 1fr));
  gap: 24px;
}

.stats-card {
  text-align: center;
  padding: 20px;
}

.stats-value {
  font-size: 3rem;
  font-weight: bold;
  color: #4080ff;
  margin: 10px 0;
}

.streak-days {
  font-size: 1.2rem;
  color: #666;
}

/* 响应式调整 */
@media (max-width: 768px) {
  .welcome-title {
    font-size: 2.2rem;
  }
  
  .welcome-subtitle {
    font-size: 1.2rem;
  }
  
  .card-grid,
  .stats-grid {
    grid-template-columns: 1fr;
  }
  
  .action-buttons {
    flex-direction: column;
    align-items: center;
  }
}
</style>
